/*
 * mibTreeModel.h
 *
 *  Created on: 2011-7-7
 *      Author: fufan
 */
#ifndef MIBTREEMODEL_H_
#define MIBTREEMODEL_H_
#include <QAbstractItemModel>
#include <QModelIndex>
#include <QVariant>
#include <QMessageBox>
#include <QIcon>
#include "mibItem.h"
#include "smi.h"
#include <iostream>
#include <string>
using namespace std;

class MibItem;

class MibTreeModel : public QAbstractItemModel
{

	Q_OBJECT

public:
	MibTreeModel(QObject *parent=0);
	~MibTreeModel();

	QModelIndex parent(const QModelIndex &index)const;
	int rowCount(const QModelIndex &parent = QModelIndex()) const;
	int columnCount(const QModelIndex &parent = QModelIndex()) const;

	QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const;
	QVariant headerData(int section, Qt::Orientation orientation,
														int role = Qt::DisplayRole) const;
	QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex())const;


private:
	void setupModel();
	void readMibNode(SmiNode *parentNode, MibItem *parentItem);
	QList<QVariant> getDatafromNode(SmiNode *smiNode) const;
	const char *getAccess(SmiAccess access) const;
	const char *getStatus(SmiStatus status) const;
	const char *getBaseType(SmiBasetype baseType) const;
	const char *getKind(SmiNodekind kind) const;
	QIcon returnIconByKind(MibItem *node) const;
	void printError(const QString& error);
	MibItem *root;
};

#endif /* MIBTREEMODEL_H_ */
